package com.example.sneakerappforme1105.dao;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import com.example.sneakerappforme1105.bean.Address;
import com.example.sneakerappforme1105.bean.Goods;

import java.util.List;

@Dao
public interface AddressDao {
    // 插入一条记录
    @Insert
    long insert(Address address);

    @Query("SELECT * FROM tb_address WHERE userId= :userId")
    List<Address> getAllAddressesByUserId(Long userId); //根据用户id,查询地址

    @Update(onConflict = OnConflictStrategy.REPLACE)// 出现重复记录时替换原记录
    int updateAddress(Address address); // 更新地址信息

    @Query("DELETE FROM tb_address WHERE addressId=:addressId AND userId=:userId")
    void deleteAddress(Long addressId, Long userId);    // 根据用户id 和 addressId删除对应的地址



}
